package com.sxt.demo.djiapplication.map.gaodemap

import android.content.Context
import android.os.Bundle
import com.amap.api.maps2d.AMap
import com.amap.api.maps2d.CameraUpdate
import com.amap.api.maps2d.MapView
import com.amap.api.maps2d.model.Marker
import com.sxt.demo.djiapplication.map.*

@Suppress("unused")
class GaoDeMap(
    override val context: Context,
    bundle: Bundle?,
    mapView: MapView
) : IMap<Marker> {

    /**
     * 地图对象
     */
    private var aMap: AMap

    init {
        mapView.onCreate(bundle)
        aMap = mapView.map
    }

    override fun setOnMapClickListener(listener: OnMapClickListener) {
        aMap.setOnMapClickListener(listener)
    }

    override fun addMarker(markerSets: MarkerSets): Marker {
        return aMap.addMarker(markerSets.getGaoDeOptions())
    }

    override fun moveCamera(action: () -> Any) {
        aMap.moveCamera(action() as CameraUpdate?)
    }

    override fun setOnMarkerClickListener(listener: OnMarkerClickListener) {
        aMap.setOnMarkerClickListener(listener)
    }

    override fun setMapLanguage(language: String) {
        aMap.setMapLanguage(language)
    }
}